home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 December / PCWorld_2007-12_cd.bin / domacnost a kancelar / autoit / autoit-v3-setup.exe / Examples / Helpfile / _IEDocInsertHTML.au3 < prev    next >
Text File  |  2007-09-08  |  3KB  |  68 lines

  1. ; *******************************************************
  2. ; Example 1 - Insert HTML at the top and bottom of a document
  3. ; *******************************************************
  4. ;
  5. #include <IE.au3>
  6. $oIE = _IECreate("http://www.autoitscript.com")
  7. $oBody = _IETagNameGetCollection($oIE, "body", 0)
  8. _IEDocInsertHTML($oBody, "<h2>This HTML is inserted After Begin</h2>", "afterbegin")
  9. _IEDocInsertHTML($oBody, "<h2>This HTML is inserted Before End</h2>", "beforeend")
  10.  
  11. ; *******************************************************
  12. ; Example 2 - Open a browser with the basic example page, insert HTML
  13. ;        in and around the DIV tag named "IEAu3Data" and display Body HTML
  14. ; *******************************************************
  15. ;
  16. $oIE = _IE_Example ("basic")
  17. $oDiv = _IEGetObjByName($oIE, "IEAu3Data")
  18.  
  19. _IEDocInsertHTML($oDiv, "<b>(HTML beforebegin)</b>", "beforebegin")
  20. _IEDocInsertHTML($oDiv, "<i>(HTML afterbegin)</i>", "afterbegin")
  21. _IEDocInsertHTML($oDiv, "<b>(HTML beforeend)</b>", "beforeend")
  22. _IEDocInsertHTML($oDiv, "<i>(HTML afterend)</i>", "afterend")
  23.  
  24. ConsoleWrite(_IEBodyReadHTML($oIE) & @CR)
  25.  
  26. ; *******************************************************
  27. ; Example 3 - Advanced example
  28. ;        Insert a clock and a referrer string at the top of every page, even when you 
  29. ;        browse to a new location.  Uses _IEDocInsertText, _IEDocInsertHTML and  
  30. ;        _IEPropertySet features "innerhtml" and "referrer"
  31. ; *******************************************************
  32. ;
  33. #include <IE.au3>
  34. $oIE = _IECreate("http://www.autoitscript.com")
  35.  
  36. AdlibEnable("UpdateClock", 1000) ; Update clock once per second
  37.  
  38. ; idle as long as the browser window exists
  39. While WinExists(_IEPropertyGet($oIE, "hwnd"))
  40.     Sleep(10000)
  41. WEnd
  42.  
  43. Exit
  44.  
  45. Func UpdateClock()
  46.     Local $curTime = "<b>Current Time is: </b>" & @HOUR & ":" & @MIN & ":" & @SEC
  47.     ; _IEGetObjByName is expected to return a NoMatch error after navigation 
  48.     ;   (before DIV is inserted), so temporarily turn off notification
  49.     _IEErrorNotify(False)
  50.     Local $oAutoItClock = _IEGetObjByName($oIE, "AutoItClock")
  51.     If Not IsObj($oAutoItClock) Then ; Insert DIV element if it wasn't found
  52.         ;
  53.         ; Get reference to BODY, insert DIV, get reference to DIV, update time
  54.         $oBody = _IETagNameGetCollection($oIE, "body", 0)
  55.         _IEDocInsertHTML($oBody, "<div id='AutoItClock'></div>", "afterbegin")
  56.         $oAutoItClock = _IEGetObjByName($oIE, "AutoItClock")
  57.         _IEPropertySet($oAutoItClock, "innerhtml", $curTime)
  58.         ;
  59.         ; Check referrer string, if not blank insert after clock
  60.         _IELoadWait($oIE)
  61.         $sReferrer = _IEPropertyGet($oIE, "referrer")
  62.         If $sReferrer Then _IEDocInsertText($oAutoItClock, _
  63.             "  Referred by: " & $sReferrer, "afterend")
  64.     Else
  65.         _IEPropertySet($oAutoItClock, "innerhtml", $curTime) ; update time
  66.     EndIf
  67.     _IEErrorNotify(True)
  68. EndFunc